import React, { useState } from 'react'
import Father from './father'


export const { Provider, Consumer } = React.createContext()
function Grandpa() {
    const [user, setUser] = useState({ username: 'aDiao', age: 20 })
    function changeMessage() {
        setUser({
            username: '阿衰',
            age: 18
        })
    }
    return (
        <div className='grandpa'>
            <h3>我是祖组件</h3>
            <h4>我的用户名是：{user.username}</h4>
            <h4>我的年龄是：{user.age}</h4>
            <button onClick={changeMessage}>点我更改信息</button>
            <Provider value={user}>
                <Father />
            </Provider>
        </div>
    )
}



export default Grandpa